package laravel.mvc.view.route;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import node.Node;

/**
 * Created by thormentor on 29-04-2014.
 */
public class Group extends Node implements IRouteElement {
    private final String group;
    private transient final ObservableList<Route> routes = FXCollections.observableArrayList();

    public Group(String group) {
        this.group = group;
    }

    @Override
    protected String getBegin() {
        return "Route::group(array('before' => '" + group + "'), function(){";
    }

    @Override
    protected String getEnd() {
        return "});";
    }

    public ObservableList<Route> getRoutes() {
        return routes;
    }

    public Route createRoute(Route.Method method, String path, String as, String uses) {
        Route route = new Route(method, path, as, uses);
        appendChild(route);
        routes.add(route);
        return route;
    }
}
